home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 1.1
/
SGI EnlightenDSM 1.1.iso
/
hp10x
/
emd.z
/
emd
/
bin
/
postinstall_agent
< prev
next >
Wrap
Text File
|
1998-06-30
|
4KB
|
181 lines
#!/bin/sh
#
# Enlighten/Events Install %W% %G%
#
# ****************************************************************
# Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
# ALL RIGHTS RESERVED WORLDWIDE
# FOR USE ONLY AS DIRECTED IN LICENSE AGREEMENT.
# ****************************************************************
# Usage: $0 <trap_host> <community>
#
umask 077
PATH=/bin:/usr/bin:/etc:/usr/ucb:/usr/bsd:/usr/etc:$PATH
export PATH
appName=`basename $0`
KEY_FILE=/etc/enlighten
#########################################################################
# Get a valid key file
#
if [ -z "$ENL_KEYS" -o ! -r "$ENL_KEYS" ] ; then
KEY_FILE=/etc/enlighten
else
KEY_FILE=$ENL_KEYS
fi
if [ ! -r "$KEY_FILE" ] ; then
echo "$appName: Fatal: Could not read file $KEY_FILE." 1>&2
echo 1>&2
if [ -f $KEY_FILE ] ; then
echo "$appName: Please run $appName as root." 1>&2
exit 1
else
echo "$appName: Reinstall Enlighten on this host." 1>&2
exit 1
fi
fi
#########################################################################
# Setup ENLIGHTEN.
#
# First try the environment variable. If that is not set properly,
# override the value with $KEY_FILE's value.
#
# If KEY_FILE is missing, '^enlighten=' is missing from KEY_FILE,
# or the directory is missing, exit.
#
if [ ! -d "$ENLIGHTEN" ] ; then
ENLIGHTEN=""
fi
if [ -z "$ENLIGHTEN" ] ; then
ENLIGHTEN=`egrep "^enlighten=" $KEY_FILE | cut "-d=" -f2-`
export ENLIGHTEN
fi
if [ -z "$ENLIGHTEN" ] ; then
echo "$appName: Fatal: Could not find the Enlighten installation directory." 1>&2
exit 1
fi
if [ ! -d "$ENLIGHTEN" ] ; then
echo "$appName: Fatal: The Enlighten directory, $ENLIGHTEN, is missing." 1>&2
exit 1
fi
LOG=/tmp/enlighten.log
BACKUPRC=n
SERVICES=/etc/services
ETC_HOSTS=/etc/hosts
CONFIG=$ENLIGHTEN/config/AgentENL.config
CONFIGBAK=$ENLIGHTEN/config/AgentENL.config.bak
#########################################################################
# Parse argv
COMMUNITY=public
HOST=`uname -n`
MANAGER=
SubDir=bin
upgrade=0
if [ $# -ge 1 ]
then
HOST=$1
fi
if [ $# -ge 2 ]
then
COMMUNITY=$2
fi
if [ $# -ge 3 ]
then
upgrade=$3
fi
#########################################################################
# Fix /etc/services file to add snmp port definitions
#
# these are the reserved port numbers for snmp
#
#
# if /etc/services is missing snmp related entries, add them
#
if [ -z "`grep snmp $SERVICES`" ] ; then
echo "snmp 161/udp" >> $SERVICES
echo "$appName: Added snmp entry to $SERVICES."
fi
if [ -z "`grep trap $SERVICES`" ] ; then
echo "snmp-trap 162/udp" >> $SERVICES
echo "$appName: Added snmp-trap entry to $SERVICES."
fi
if [ -z "`grep smux $SERVICES`" ] ; then
echo "smux 199/tcp" >> $SERVICES
echo "$appName: Added smux entry to $SERVICES."
fi
#########################################################################
# Fix AgentENL.conf file
if [ ! -f $CONFIG ]
then
echo "$appName: Fatal: Could not find $CONFIG." 2>&1
exit 1;
fi
chown root $CONFIG
chmod 600 $CONFIG
if [ ! -w $CONFIG ]
then
echo "$appName: Fatal: Could not find/write $CONFIG." 1>&2
exit 1 ;
fi
#
# If upgrading copy old config file back into place.
# Otherwise, update the file.
#
if [ "$upgrade" -eq 1 ] ; then
if [ -f $CONFIGBAK ] ; then
cp $CONFIG ${CONFIG}.new
cp $CONFIGBAK $CONFIG
fi
else
OLD_MANAGER=`grep \^MANAGER $CONFIG | awk '{printf "%s",$2}' `
if [ -z "$OLD_MANAGER" ] ; then
echo "$appName: Fatal: $CONFIG was corrupt." 1>&2
exit 1 ;
fi
OLD_COMMUNITY=`grep \^COMMUNITY $CONFIG | awk '{printf "%s",$2}' `
if [ -z "$OLD_COMMUNITY" ] ; then
echo "$appName: Fatal: $CONFIG was corrupt." 1>&2
exit 1 ;
fi
cp $CONFIG $CONFIG.bak
cat $CONFIG | sed -e "s/$OLD_MANAGER/$HOST/" > $CONFIG.tmp
cat $CONFIG.tmp | sed -e "s/$OLD_COMMUNITY/$COMMUNITY/" > $CONFIG
rm $CONFIG.tmp
fi
echo "$appName: Finished configuration successfully."
exit 0